{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e4a3ecb7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Description: Baichuan-13B可商用中文大模型微调演示\n",
    "# Copyright: 北京海之翼科技有限公司\n",
    "# Author: zhouxuhui\n",
    "# Date: 2023-09-16"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d4b763c7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n",
      "Collecting accelerate==0.21.0\n",
      "  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/70/f9/c381bcdd0c3829d723aa14eec8e75c6c377b4ca61ec68b8093d9f35fc7a7/accelerate-0.21.0-py3-none-any.whl (244 kB)\n",
      "Collecting transformers==4.30.2\n",
      "  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/5b/0b/e45d26ccd28568013523e04f325432ea88a442b4e3020b757cf4361f0120/transformers-4.30.2-py3-none-any.whl (7.2 MB)\n",
      "Collecting peft==0.4.0\n",
      "  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/88/a0/6e1c23293a922a9c9e9bd8d56a60cd78ecf531fdabe45ac975e142bfbe86/peft-0.4.0-py3-none-any.whl (72 kB)\n",
      "Collecting bitsandbytes==0.39.0\n",
      "  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/9c/ef/ddedb4a3d81d1bb7ffc4633f38fbdf1fd69d9e73cc0ac3c8be31a9c3fe20/bitsandbytes-0.39.0-py3-none-any.whl (92.2 MB)\n",
      "Requirement already satisfied: loguru==0.7.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 5)) (0.7.0)\n",
      "Requirement already satisfied: numpy==1.21.4 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 6)) (1.21.4)\n",
      "Requirement already satisfied: pandas==1.2.5 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 7)) (1.2.5)\n",
      "Requirement already satisfied: tqdm==4.62.3 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 8)) (4.62.3)\n",
      "Requirement already satisfied: deepspeed==0.9.5 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 9)) (0.9.5)\n",
      "Requirement already satisfied: tensorboard in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 10)) (2.14.0)\n",
      "Requirement already satisfied: sentencepiece in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 11)) (0.1.97)\n",
      "Requirement already satisfied: transformers_stream_generator in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 12)) (0.0.4)\n",
      "Requirement already satisfied: tiktoken in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 13)) (0.4.0)\n",
      "Requirement already satisfied: einops in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 14)) (0.6.0)\n",
      "Requirement already satisfied: httpx in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 15)) (0.23.3)\n",
      "Requirement already satisfied: scipy in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 16)) (1.10.1)\n",
      "Requirement already satisfied: torch==1.13.1 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 17)) (1.13.1)\n",
      "Requirement already satisfied: mmengine in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 18)) (0.8.4)\n",
      "Requirement already satisfied: xformers in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from -r requirements.txt (line 19)) (0.0.16)\n",
      "Requirement already satisfied: packaging>=20.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from accelerate==0.21.0->-r requirements.txt (line 1)) (23.1)\n",
      "Requirement already satisfied: psutil in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from accelerate==0.21.0->-r requirements.txt (line 1)) (5.9.5)\n",
      "Requirement already satisfied: pyyaml in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from accelerate==0.21.0->-r requirements.txt (line 1)) (5.4.1)\n",
      "Requirement already satisfied: huggingface-hub<1.0,>=0.14.1 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from transformers==4.30.2->-r requirements.txt (line 2)) (0.15.1)\n",
      "Requirement already satisfied: requests in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from transformers==4.30.2->-r requirements.txt (line 2)) (2.31.0)\n",
      "Requirement already satisfied: filelock in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from transformers==4.30.2->-r requirements.txt (line 2)) (3.9.0)\n",
      "Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from transformers==4.30.2->-r requirements.txt (line 2)) (0.13.3)\n",
      "Requirement already satisfied: safetensors>=0.3.1 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from transformers==4.30.2->-r requirements.txt (line 2)) (0.3.1)\n",
      "Requirement already satisfied: regex!=2019.12.17 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from transformers==4.30.2->-r requirements.txt (line 2)) (2022.10.31)\n",
      "Requirement already satisfied: python-dateutil>=2.7.3 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from pandas==1.2.5->-r requirements.txt (line 7)) (2.8.2)\n",
      "Requirement already satisfied: pytz>=2017.3 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from pandas==1.2.5->-r requirements.txt (line 7)) (2022.7.1)\n",
      "Requirement already satisfied: py-cpuinfo in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from deepspeed==0.9.5->-r requirements.txt (line 9)) (9.0.0)\n",
      "Requirement already satisfied: ninja in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from deepspeed==0.9.5->-r requirements.txt (line 9)) (1.11.1)\n",
      "Requirement already satisfied: pydantic<2.0.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from deepspeed==0.9.5->-r requirements.txt (line 9)) (1.10.11)\n",
      "Requirement already satisfied: hjson in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from deepspeed==0.9.5->-r requirements.txt (line 9)) (3.1.0)\n",
      "Requirement already satisfied: typing_extensions in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from torch==1.13.1->-r requirements.txt (line 17)) (4.4.0)\n",
      "Requirement already satisfied: wheel>=0.26 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from tensorboard->-r requirements.txt (line 10)) (0.38.4)\n",
      "Requirement already satisfied: protobuf>=3.19.6 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from tensorboard->-r requirements.txt (line 10)) (3.20.0)\n",
      "Requirement already satisfied: werkzeug>=1.0.1 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from tensorboard->-r requirements.txt (line 10)) (2.3.6)\n",
      "Requirement already satisfied: absl-py>=0.4 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from tensorboard->-r requirements.txt (line 10)) (1.4.0)\n",
      "Requirement already satisfied: markdown>=2.6.8 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from tensorboard->-r requirements.txt (line 10)) (3.4.3)\n",
      "Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from tensorboard->-r requirements.txt (line 10)) (0.7.1)\n",
      "Requirement already satisfied: google-auth<3,>=1.6.3 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from tensorboard->-r requirements.txt (line 10)) (2.22.0)\n",
      "Requirement already satisfied: google-auth-oauthlib<1.1,>=0.5 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from tensorboard->-r requirements.txt (line 10)) (1.0.0)\n",
      "Requirement already satisfied: grpcio>=1.48.2 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from tensorboard->-r requirements.txt (line 10)) (1.57.0)\n",
      "Requirement already satisfied: setuptools>=41.0.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from tensorboard->-r requirements.txt (line 10)) (67.5.1)\n",
      "Requirement already satisfied: sniffio in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from httpx->-r requirements.txt (line 15)) (1.3.0)\n",
      "Requirement already satisfied: rfc3986[idna2008]<2,>=1.3 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from httpx->-r requirements.txt (line 15)) (1.5.0)\n",
      "Requirement already satisfied: certifi in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from httpx->-r requirements.txt (line 15)) (2023.7.22)\n",
      "Requirement already satisfied: httpcore<0.17.0,>=0.15.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from httpx->-r requirements.txt (line 15)) (0.16.3)\n",
      "Requirement already satisfied: rich in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from mmengine->-r requirements.txt (line 18)) (13.0.1)\n",
      "Requirement already satisfied: yapf in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from mmengine->-r requirements.txt (line 18)) (0.40.1)\n",
      "Requirement already satisfied: opencv-python>=3 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from mmengine->-r requirements.txt (line 18)) (4.6.0.66)\n",
      "Requirement already satisfied: matplotlib in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from mmengine->-r requirements.txt (line 18)) (3.7.1)\n",
      "Requirement already satisfied: termcolor in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from mmengine->-r requirements.txt (line 18)) (2.2.0)\n",
      "Requirement already satisfied: addict in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from mmengine->-r requirements.txt (line 18)) (2.4.0)\n",
      "Requirement already satisfied: pyre-extensions==0.0.23 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from xformers->-r requirements.txt (line 19)) (0.0.23)\n",
      "Requirement already satisfied: typing-inspect in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from pyre-extensions==0.0.23->xformers->-r requirements.txt (line 19)) (0.8.0)\n",
      "Requirement already satisfied: urllib3<2.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard->-r requirements.txt (line 10)) (1.26.14)\n",
      "Requirement already satisfied: rsa<5,>=3.1.4 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard->-r requirements.txt (line 10)) (4.9)\n",
      "Requirement already satisfied: six>=1.9.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard->-r requirements.txt (line 10)) (1.16.0)\n",
      "Requirement already satisfied: cachetools<6.0,>=2.0.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard->-r requirements.txt (line 10)) (5.3.0)\n",
      "Requirement already satisfied: pyasn1-modules>=0.2.1 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard->-r requirements.txt (line 10)) (0.3.0)\n",
      "Requirement already satisfied: requests-oauthlib>=0.7.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from google-auth-oauthlib<1.1,>=0.5->tensorboard->-r requirements.txt (line 10)) (1.3.1)\n",
      "Requirement already satisfied: h11<0.15,>=0.13 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from httpcore<0.17.0,>=0.15.0->httpx->-r requirements.txt (line 15)) (0.14.0)\n",
      "Requirement already satisfied: anyio<5.0,>=3.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from httpcore<0.17.0,>=0.15.0->httpx->-r requirements.txt (line 15)) (3.6.2)\n",
      "Requirement already satisfied: fsspec in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from huggingface-hub<1.0,>=0.14.1->transformers==4.30.2->-r requirements.txt (line 2)) (2023.3.0)\n",
      "Requirement already satisfied: importlib-metadata>=4.4 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from markdown>=2.6.8->tensorboard->-r requirements.txt (line 10)) (6.8.0)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from requests->transformers==4.30.2->-r requirements.txt (line 2)) (2.1.0)\n",
      "Requirement already satisfied: idna<4,>=2.5 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from requests->transformers==4.30.2->-r requirements.txt (line 2)) (3.4)\n",
      "Requirement already satisfied: MarkupSafe>=2.1.1 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from werkzeug>=1.0.1->tensorboard->-r requirements.txt (line 10)) (2.1.2)\n",
      "Requirement already satisfied: pillow>=6.2.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from matplotlib->mmengine->-r requirements.txt (line 18)) (9.4.0)\n",
      "Requirement already satisfied: fonttools>=4.22.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from matplotlib->mmengine->-r requirements.txt (line 18)) (4.39.0)\n",
      "Requirement already satisfied: cycler>=0.10 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from matplotlib->mmengine->-r requirements.txt (line 18)) (0.11.0)\n",
      "Requirement already satisfied: contourpy>=1.0.1 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from matplotlib->mmengine->-r requirements.txt (line 18)) (1.0.7)\n",
      "Requirement already satisfied: importlib-resources>=3.2.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from matplotlib->mmengine->-r requirements.txt (line 18)) (5.12.0)\n",
      "Requirement already satisfied: kiwisolver>=1.0.1 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from matplotlib->mmengine->-r requirements.txt (line 18)) (1.4.4)\n",
      "Requirement already satisfied: pyparsing>=2.3.1 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from matplotlib->mmengine->-r requirements.txt (line 18)) (3.0.9)\n",
      "Requirement already satisfied: commonmark<0.10.0,>=0.9.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from rich->mmengine->-r requirements.txt (line 18)) (0.9.1)\n",
      "Requirement already satisfied: pygments<3.0.0,>=2.6.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from rich->mmengine->-r requirements.txt (line 18)) (2.16.1)\n",
      "Requirement already satisfied: platformdirs>=3.5.1 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from yapf->mmengine->-r requirements.txt (line 18)) (3.10.0)\n",
      "Requirement already satisfied: tomli>=2.0.1 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from yapf->mmengine->-r requirements.txt (line 18)) (2.0.1)\n",
      "Requirement already satisfied: zipp>=0.5 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from importlib-metadata>=4.4->markdown>=2.6.8->tensorboard->-r requirements.txt (line 10)) (3.16.2)\n",
      "Requirement already satisfied: pyasn1<0.6.0,>=0.4.6 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard->-r requirements.txt (line 10)) (0.5.0)\n",
      "Requirement already satisfied: oauthlib>=3.0.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<1.1,>=0.5->tensorboard->-r requirements.txt (line 10)) (3.2.2)\n",
      "Requirement already satisfied: mypy-extensions>=0.3.0 in /home/sre/anaconda3/envs/gpt/lib/python3.8/site-packages (from typing-inspect->pyre-extensions==0.0.23->xformers->-r requirements.txt (line 19)) (1.0.0)\n",
      "Installing collected packages: bitsandbytes, accelerate, transformers, peft\n",
      "  Attempting uninstall: bitsandbytes\n",
      "    Found existing installation: bitsandbytes 0.41.1\n",
      "    Uninstalling bitsandbytes-0.41.1:\n",
      "      Successfully uninstalled bitsandbytes-0.41.1\n",
      "  Attempting uninstall: accelerate\n",
      "    Found existing installation: accelerate 0.24.0.dev0\n",
      "    Uninstalling accelerate-0.24.0.dev0:\n",
      "      Successfully uninstalled accelerate-0.24.0.dev0\n",
      "  Attempting uninstall: transformers\n",
      "    Found existing installation: transformers 4.34.0.dev0\n",
      "    Uninstalling transformers-4.34.0.dev0:\n",
      "      Successfully uninstalled transformers-4.34.0.dev0\n",
      "  Attempting uninstall: peft\n",
      "    Found existing installation: peft 0.6.0.dev0\n",
      "    Uninstalling peft-0.6.0.dev0:\n",
      "      Successfully uninstalled peft-0.6.0.dev0\n",
      "Successfully installed accelerate-0.21.0 bitsandbytes-0.39.0 peft-0.4.0 transformers-4.30.2\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "pip install -r requirements.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "f0f97963",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n",
      "Collecting git+https://github.com/huggingface/peft.git\n",
      "  Cloning https://github.com/huggingface/peft.git to /tmp/pip-req-build-2kz42aa_\n",
      "  Running command git clone --filter=blob:none --quiet https://github.com/huggingface/peft.git /tmp/pip-req-build-2kz42aa_\n",
      "  Resolved https://github.com/huggingface/peft.git to commit 6b4554e6437a372177d16a7800df8cfd03fbd16f\n",
      "  Installing build dependencies ... \u001b[?25ldone\n",
      "\u001b[?25h  Getting requirements to build wheel ... \u001b[?25ldone\n",
      "\u001b[?25h  Preparing metadata (pyproject.toml) ... \u001b[?25ldone\n",
      "\u001b[?25hRequirement already satisfied: pyyaml in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from peft==0.6.0.dev0) (6.0)\n",
      "Requirement already satisfied: torch>=1.13.0 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from peft==0.6.0.dev0) (2.0.0)\n",
      "Requirement already satisfied: safetensors in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from peft==0.6.0.dev0) (0.3.1)\n",
      "Requirement already satisfied: packaging>=20.0 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from peft==0.6.0.dev0) (23.0)\n",
      "Requirement already satisfied: tqdm in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from peft==0.6.0.dev0) (4.65.0)\n",
      "Requirement already satisfied: transformers in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from peft==0.6.0.dev0) (4.29.1)\n",
      "Requirement already satisfied: numpy>=1.17 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from peft==0.6.0.dev0) (1.23.5)\n",
      "Collecting accelerate>=0.21.0\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d9/92/2d3aecf9f4a192968035880be3e2fc8b48d541c7128f7c936f430d6f96da/accelerate-0.23.0-py3-none-any.whl (258 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m258.1/258.1 kB\u001b[0m \u001b[31m9.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: psutil in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from peft==0.6.0.dev0) (5.9.4)\n",
      "Requirement already satisfied: huggingface-hub in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from accelerate>=0.21.0->peft==0.6.0.dev0) (0.16.4)\n",
      "Requirement already satisfied: filelock in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from torch>=1.13.0->peft==0.6.0.dev0) (3.10.0)\n",
      "Requirement already satisfied: typing-extensions in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from torch>=1.13.0->peft==0.6.0.dev0) (4.5.0)\n",
      "Requirement already satisfied: sympy in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from torch>=1.13.0->peft==0.6.0.dev0) (1.11.1)\n",
      "Requirement already satisfied: networkx in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from torch>=1.13.0->peft==0.6.0.dev0) (3.0)\n",
      "Requirement already satisfied: jinja2 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from torch>=1.13.0->peft==0.6.0.dev0) (3.1.2)\n",
      "Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from transformers->peft==0.6.0.dev0) (0.13.2)\n",
      "Requirement already satisfied: requests in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from transformers->peft==0.6.0.dev0) (2.28.2)\n",
      "Requirement already satisfied: regex!=2019.12.17 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from transformers->peft==0.6.0.dev0) (2022.10.31)\n",
      "Requirement already satisfied: fsspec in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from huggingface-hub->accelerate>=0.21.0->peft==0.6.0.dev0) (2023.3.0)\n",
      "Requirement already satisfied: MarkupSafe>=2.0 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from jinja2->torch>=1.13.0->peft==0.6.0.dev0) (2.1.2)\n",
      "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from requests->transformers->peft==0.6.0.dev0) (1.26.15)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from requests->transformers->peft==0.6.0.dev0) (2.1.0)\n",
      "Requirement already satisfied: idna<4,>=2.5 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from requests->transformers->peft==0.6.0.dev0) (3.4)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from requests->transformers->peft==0.6.0.dev0) (2022.12.7)\n",
      "Requirement already satisfied: mpmath>=0.19 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from sympy->torch>=1.13.0->peft==0.6.0.dev0) (1.3.0)\n",
      "Building wheels for collected packages: peft\n",
      "  Building wheel for peft (pyproject.toml) ... \u001b[?25ldone\n",
      "\u001b[?25h  Created wheel for peft: filename=peft-0.6.0.dev0-py3-none-any.whl size=107864 sha256=b050fa0c8cf0b6dd8a6b57fb20da4c53f44c59d19f09be444b4e37ea33a0c611\n",
      "  Stored in directory: /tmp/pip-ephem-wheel-cache-trr4a9ny/wheels/d7/c7/de/1368fac8590e1b103ddc2ec2a28ad51d83aded1a3830e8a087\n",
      "Successfully built peft\n",
      "Installing collected packages: accelerate, peft\n",
      "  Attempting uninstall: accelerate\n",
      "    Found existing installation: accelerate 0.17.1\n",
      "    Uninstalling accelerate-0.17.1:\n",
      "      Successfully uninstalled accelerate-0.17.1\n",
      "  Attempting uninstall: peft\n",
      "    Found existing installation: peft 0.3.0.dev0\n",
      "    Uninstalling peft-0.3.0.dev0:\n",
      "      Successfully uninstalled peft-0.3.0.dev0\n",
      "Successfully installed accelerate-0.23.0 peft-0.6.0.dev0\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "pip install git+https://github.com/huggingface/peft.git"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "a5b87947",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n",
      "Collecting git+https://github.com/huggingface/accelerate.git\n",
      "  Cloning https://github.com/huggingface/accelerate.git to /tmp/pip-req-build-k86le4pg\n",
      "  Running command git clone --filter=blob:none --quiet https://github.com/huggingface/accelerate.git /tmp/pip-req-build-k86le4pg\n",
      "  Resolved https://github.com/huggingface/accelerate.git to commit a87c95da9e3b416fb10a0e7dac7d397c015c3ed5\n",
      "  Installing build dependencies ... \u001b[?25ldone\n",
      "\u001b[?25h  Getting requirements to build wheel ... \u001b[?25ldone\n",
      "\u001b[?25h  Preparing metadata (pyproject.toml) ... \u001b[?25ldone\n",
      "\u001b[?25hRequirement already satisfied: pyyaml in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from accelerate==0.24.0.dev0) (6.0)\n",
      "Requirement already satisfied: numpy>=1.17 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from accelerate==0.24.0.dev0) (1.23.5)\n",
      "Requirement already satisfied: huggingface-hub in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from accelerate==0.24.0.dev0) (0.16.4)\n",
      "Requirement already satisfied: psutil in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from accelerate==0.24.0.dev0) (5.9.4)\n",
      "Requirement already satisfied: packaging>=20.0 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from accelerate==0.24.0.dev0) (23.0)\n",
      "Requirement already satisfied: torch>=1.10.0 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from accelerate==0.24.0.dev0) (2.0.0)\n",
      "Requirement already satisfied: filelock in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from torch>=1.10.0->accelerate==0.24.0.dev0) (3.10.0)\n",
      "Requirement already satisfied: typing-extensions in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from torch>=1.10.0->accelerate==0.24.0.dev0) (4.5.0)\n",
      "Requirement already satisfied: sympy in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from torch>=1.10.0->accelerate==0.24.0.dev0) (1.11.1)\n",
      "Requirement already satisfied: networkx in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from torch>=1.10.0->accelerate==0.24.0.dev0) (3.0)\n",
      "Requirement already satisfied: jinja2 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from torch>=1.10.0->accelerate==0.24.0.dev0) (3.1.2)\n",
      "Requirement already satisfied: tqdm>=4.42.1 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from huggingface-hub->accelerate==0.24.0.dev0) (4.65.0)\n",
      "Requirement already satisfied: requests in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from huggingface-hub->accelerate==0.24.0.dev0) (2.28.2)\n",
      "Requirement already satisfied: fsspec in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from huggingface-hub->accelerate==0.24.0.dev0) (2023.3.0)\n",
      "Requirement already satisfied: MarkupSafe>=2.0 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from jinja2->torch>=1.10.0->accelerate==0.24.0.dev0) (2.1.2)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from requests->huggingface-hub->accelerate==0.24.0.dev0) (2.1.0)\n",
      "Requirement already satisfied: idna<4,>=2.5 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from requests->huggingface-hub->accelerate==0.24.0.dev0) (3.4)\n",
      "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from requests->huggingface-hub->accelerate==0.24.0.dev0) (1.26.15)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from requests->huggingface-hub->accelerate==0.24.0.dev0) (2022.12.7)\n",
      "Requirement already satisfied: mpmath>=0.19 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from sympy->torch>=1.10.0->accelerate==0.24.0.dev0) (1.3.0)\n",
      "Building wheels for collected packages: accelerate\n",
      "  Building wheel for accelerate (pyproject.toml) ... \u001b[?25ldone\n",
      "\u001b[?25h  Created wheel for accelerate: filename=accelerate-0.24.0.dev0-py3-none-any.whl size=258134 sha256=97298b47a8288d8454c09e87147faeac0ffd09bae28c558338e1bf77df78aeec\n",
      "  Stored in directory: /tmp/pip-ephem-wheel-cache-vb4pxa6j/wheels/9c/a3/1e/47368f9b6575655fe9ee1b6350cfa7d4b0befe66a35f8a8365\n",
      "Successfully built accelerate\n",
      "Installing collected packages: accelerate\n",
      "  Attempting uninstall: accelerate\n",
      "    Found existing installation: accelerate 0.23.0\n",
      "    Uninstalling accelerate-0.23.0:\n",
      "      Successfully uninstalled accelerate-0.23.0\n",
      "Successfully installed accelerate-0.24.0.dev0\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "pip install git+https://github.com/huggingface/accelerate.git"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9366434d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n",
      "Collecting git+https://github.com/huggingface/transformers.git\n",
      "  Cloning https://github.com/huggingface/transformers.git to /tmp/pip-req-build-vpmcjsk0\n",
      "  Running command git clone --filter=blob:none --quiet https://github.com/huggingface/transformers.git /tmp/pip-req-build-vpmcjsk0\n",
      "  Resolved https://github.com/huggingface/transformers.git to commit 0a55d9f7376f72ad3ff296d4249840021b03bcc4\n",
      "  Installing build dependencies ... \u001b[?25ldone\n",
      "\u001b[?25h  Getting requirements to build wheel ... \u001b[?25ldone\n",
      "\u001b[?25h  Preparing metadata (pyproject.toml) ... \u001b[?25ldone\n",
      "\u001b[?25hRequirement already satisfied: regex!=2019.12.17 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from transformers==4.34.0.dev0) (2022.10.31)\n",
      "Requirement already satisfied: requests in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from transformers==4.34.0.dev0) (2.28.2)\n",
      "Requirement already satisfied: safetensors>=0.3.1 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from transformers==4.34.0.dev0) (0.3.1)\n",
      "Requirement already satisfied: filelock in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from transformers==4.34.0.dev0) (3.10.0)\n",
      "Requirement already satisfied: huggingface-hub<1.0,>=0.15.1 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from transformers==4.34.0.dev0) (0.16.4)\n",
      "Requirement already satisfied: packaging>=20.0 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from transformers==4.34.0.dev0) (23.0)\n",
      "Requirement already satisfied: tqdm>=4.27 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from transformers==4.34.0.dev0) (4.65.0)\n",
      "Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from transformers==4.34.0.dev0) (0.13.2)\n",
      "Requirement already satisfied: pyyaml>=5.1 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from transformers==4.34.0.dev0) (6.0)\n",
      "Requirement already satisfied: numpy>=1.17 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from transformers==4.34.0.dev0) (1.23.5)\n",
      "Requirement already satisfied: fsspec in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from huggingface-hub<1.0,>=0.15.1->transformers==4.34.0.dev0) (2023.3.0)\n",
      "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from huggingface-hub<1.0,>=0.15.1->transformers==4.34.0.dev0) (4.5.0)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from requests->transformers==4.34.0.dev0) (2022.12.7)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from requests->transformers==4.34.0.dev0) (2.1.0)\n",
      "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from requests->transformers==4.34.0.dev0) (1.26.15)\n",
      "Requirement already satisfied: idna<4,>=2.5 in /home/sre/anaconda3/envs/bab/lib/python3.10/site-packages (from requests->transformers==4.34.0.dev0) (3.4)\n",
      "Building wheels for collected packages: transformers\n",
      "  Building wheel for transformers (pyproject.toml) ... \u001b[?25ldone\n",
      "\u001b[?25h  Created wheel for transformers: filename=transformers-4.34.0.dev0-py3-none-any.whl size=7683006 sha256=5ad154f3e30e429600f76b98331a69e4eff2bd3e85ba069789742cc324f54081\n",
      "  Stored in directory: /tmp/pip-ephem-wheel-cache-oxk4xkoq/wheels/e7/9c/5b/e1a9c8007c343041e61cc484433d512ea9274272e3fcbe7c16\n",
      "Successfully built transformers\n",
      "Installing collected packages: transformers\n",
      "  Attempting uninstall: transformers\n",
      "    Found existing installation: transformers 4.29.1\n",
      "    Uninstalling transformers-4.29.1:\n",
      "      Successfully uninstalled transformers-4.29.1\n",
      "Successfully installed transformers-4.34.0.dev0\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "pip install git+https://github.com/huggingface/transformers.git"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "2ca1142e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n",
      "Collecting git+https://github.com/TimDettmers/bitsandbytes.git\n",
      "  Cloning https://github.com/TimDettmers/bitsandbytes.git to /tmp/pip-req-build-m0q94594\n",
      "  Running command git clone --filter=blob:none --quiet https://github.com/TimDettmers/bitsandbytes.git /tmp/pip-req-build-m0q94594\n",
      "  Resolved https://github.com/TimDettmers/bitsandbytes.git to commit 18e827d666fa2b70a12d539ccedc17aa51b2c97c\n",
      "  Installing build dependencies ... \u001b[?25ldone\n",
      "\u001b[?25h  Getting requirements to build wheel ... \u001b[?25ldone\n",
      "\u001b[?25h  Preparing metadata (pyproject.toml) ... \u001b[?25ldone\n",
      "\u001b[?25hBuilding wheels for collected packages: bitsandbytes\n",
      "  Building wheel for bitsandbytes (pyproject.toml) ... \u001b[?25ldone\n",
      "\u001b[?25h  Created wheel for bitsandbytes: filename=bitsandbytes-0.41.1-py3-none-any.whl size=75644 sha256=b82426b6964230cc8782ad5fb2c3f58d1e35f9e5564caf506046140f5720d8e8\n",
      "  Stored in directory: /tmp/pip-ephem-wheel-cache-3zvdsy_x/wheels/60/a4/86/927dc21b394281798da74269aa21a13d8252d5df455647d894\n",
      "Successfully built bitsandbytes\n",
      "Installing collected packages: bitsandbytes\n",
      "  Attempting uninstall: bitsandbytes\n",
      "    Found existing installation: bitsandbytes 0.39.0\n",
      "    Uninstalling bitsandbytes-0.39.0:\n",
      "      Successfully uninstalled bitsandbytes-0.39.0\n",
      "Successfully installed bitsandbytes-0.41.1\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "pip install git+https://github.com/TimDettmers/bitsandbytes.git"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a464ab0a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Found existing installation: gradio 3.28.3\n",
      "Uninstalling gradio-3.28.3:\n",
      "  Successfully uninstalled gradio-3.28.3\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "# 如果报错gradio版本过高，可以用这个命令删除包再安装\n",
    "#pip uninstall -y gradio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e4b4ae2e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数据格式\n",
    "# 中英文一样\n",
    "# 单轮\n",
    "item1 = {\"conversation_id\": 1, \"category\": \"Brainstorming\", \"conversation\": [{\"human\": \"请问怎样避免在项目中出现拖延？\", \"assistant\": \"避免拖延的方法有很多，以下是一些可行的建议：\\n\\n1. 制定计划和时间表：在项目开始时，制定一个详细的计划和时间表，包括每个任务的截止日期和所需时间。这样可以确保您有足够的时间来完成每个任务，并且能够更好地管理时间。\\n\\n2. 分解任务：将大型任务分解成更小、更具体的任务，这样您就可以更好地管理时间和进度。通过分解任务，您可以更好地掌握每个任务的优先级和所需时间。\\n\\n3. 减少干扰：在工作期间，尽量避免干扰和分心。关闭手机通知，将电子邮件通知设置为仅在特定时间显示，避免与同事过多的交流等。\\n\\n4. 留出缓冲时间：在计划和时间表中留出一些缓冲时间，以便在出现紧急情况或出现延误时进行调整。\\n\\n5. 与他人交流：如果您预计无法按时完成任务，请及早与团队成员或领导进行沟通。这样可以确保团队明确任务的状态，并且可以及时调整计划和时间表。\\n\\n6. 奖励自己：在完成重要任务或任务阶段后，给自己一个小小的奖励，这样可以提高自我动力，鼓励自己更好地管理时间和计划。\"}]}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5034c2a4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "    \"conversation_id\": 1,\n",
      "    \"category\": \"Brainstorming\",\n",
      "    \"conversation\": [\n",
      "        {\n",
      "            \"human\": \"请问怎样避免在项目中出现拖延？\",\n",
      "            \"assistant\": \"避免拖延的方法有很多，以下是一些可行的建议：\\n\\n1. 制定计划和时间表：在项目开始时，制定一个详细的计划和时间表，包括每个任务的截止日期和所需时间。这样可以确保您有足够的时间来完成每个任务，并且能够更好地管理时间。\\n\\n2. 分解任务：将大型任务分解成更小、更具体的任务，这样您就可以更好地管理时间和进度。通过分解任务，您可以更好地掌握每个任务的优先级和所需时间。\\n\\n3. 减少干扰：在工作期间，尽量避免干扰和分心。关闭手机通知，将电子邮件通知设置为仅在特定时间显示，避免与同事过多的交流等。\\n\\n4. 留出缓冲时间：在计划和时间表中留出一些缓冲时间，以便在出现紧急情况或出现延误时进行调整。\\n\\n5. 与他人交流：如果您预计无法按时完成任务，请及早与团队成员或领导进行沟通。这样可以确保团队明确任务的状态，并且可以及时调整计划和时间表。\\n\\n6. 奖励自己：在完成重要任务或任务阶段后，给自己一个小小的奖励，这样可以提高自我动力，鼓励自己更好地管理时间和计划。\"\n",
      "        }\n",
      "    ]\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "# 将JSON结构转换为格式美观的字符串\n",
    "import json\n",
    "output = json.dumps(item1, indent=4, ensure_ascii=False)\n",
    "print(output)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "71478b0a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "    \"conversation_id\": 2,\n",
      "    \"category\": \"Brainstorming\",\n",
      "    \"conversation\": [\n",
      "        {\n",
      "            \"human\": \"请问怎样避免在项目中出现拖延？\",\n",
      "            \"assistant\": \"避免拖延的方法有很多，以下是一些可行的建议：\\n\\n1. 制定计划和时间表：在项目开始时，制定一个详细的计划和时间表，包括每个任务的截止日期和所需时间。这样可以确保您有足够的时间来完成每个任务，并且能够更好地管理时间。\\n\\n2. 分解任务：将大型任务分解成更小、更具体的任务，这样您就可以更好地管理时间和进度。通过分解任务，您可以更好地掌握每个任务的优先级和所需时间。\\n\\n3. 减少干扰：在工作期间，尽量避免干扰和分心。关闭手机通知，将电子邮件通知设置为仅在特定时间显示，避免与同事过多的交流等。\\n\\n4. 留出缓冲时间：在计划和时间表中留出一些缓冲时间，以便在出现紧急情况或出现延误时进行调整。\\n\\n5. 与他人交流：如果您预计无法按时完成任务，请及早与团队成员或领导进行沟通。这样可以确保团队明确任务的状态，并且可以及时调整计划和时间表。\\n\\n6. 奖励自己：在完成重要任务或任务阶段后，给自己一个小小的奖励，这样可以提高自我动力，鼓励自己更好地管理时间和计划。\"\n",
      "        },\n",
      "        {\n",
      "            \"human\": \"对于一个团队来说，如何协调成员的进度和时间表？\",\n",
      "            \"assistant\": \"协调团队成员的进度和时间表是团队管理的重要方面。以下是一些建议：\\n\\n1. 确定任务和优先级：确定团队需要完成的任务，将它们分解成更小的任务，并确定每个任务的优先级。这有助于团队成员了解哪些任务更重要，需要更多的时间和资源。\\n\\n2. 制定时间表：根据任务和优先级，制定一个时间表和截止日期。确保每个团队成员都知道自己需要在何时完成任务。\\n\\n3. 留出缓冲时间：在时间表中留出一些缓冲时间，以便团队成员可以在出现延误时进行调整。\\n\\n4. 确定团队成员的可用时间：了解每个团队成员的可用时间，例如他们是否有其他项目或任务需要完成。这有助于制定更合理的时间表，并避免出现时间冲突。\\n\\n5. 沟通和协调：定期与团队成员进行沟通，了解任务的进度和状态。如果有延误或出现问题，及时进行协调和调整时间表。\\n\\n6. 使用项目管理工具：使用项目管理工具如Trello、Asana等，可以帮助团队成员共享任务和时间表，并确保每个人都了解任务的状态和优先级。\"\n",
      "        },\n",
      "        {\n",
      "            \"human\": \"对于团队协作中出现的冲突，有什么好的解决方法吗？\",\n",
      "            \"assistant\": \"团队协作中出现的冲突是非常常见的，以下是一些解决方法：\\n\\n1. 沟通：通过沟通，了解每个人的观点和利益，尝试达成共识。在沟通中要保持冷静，尊重他人的意见，以及表达自己的观点。\\n\\n2. 寻求中立的第三方：如果冲突无法通过沟通解决，可以寻求一个中立的第三方来帮助解决问题。这个第三方可以是团队领导、人事部门或其他人。\\n\\n3. 找出根本原因：为了解决冲突，需要找出背后的根本原因。只有了解了根本原因，才能找到解决方法。\\n\\n4. 寻找妥协方案：寻找妥协方案是解决冲突的另一种方法。通过找到双方都能接受的方案，可以解决冲突并维持团队的和谐。\\n\\n5. 集体决策：对于一些重要的决策，可以通过集体决策来解决冲突。这可以确保每个人都有机会发表意见，并在团队中达成共识。\\n\\n6. 接受和解：如果无法通过其他方法解决冲突，那么双方都需要接受和解。这意味着双方都需要放下过去的不满和情绪，重新开始合作。\"\n",
      "        },\n",
      "        {\n",
      "            \"human\": \"请问如何处理团队成员的低效率问题？\",\n",
      "            \"assistant\": \"处理团队成员的低效率问题需要考虑以下几个方面：\\n\\n1.了解原因：了解低效率的原因是解决问题的第一步。可能有多种原因导致低效率，例如缺乏技能、缺乏经验、不明确的任务、缺乏资源等。只有了解原因，才能有针对性地解决问题。\\n\\n2.提供培训和支持：如果低效率是由于缺乏技能或经验导致的，可以提供必要的培训和支持，帮助团队成员提高技能水平和工作效率。\\n\\n3.明确任务和目标：为了避免团队成员低效率，任务和目标必须清晰明确。如果任务和目标不清晰，可能会导致团队成员浪费时间和精力，无法有效地完成任务。\\n\\n4.提供必要的资源：低效率可能是由于缺乏必要的资源导致的。为了提高工作效率，必须为团队成员提供必要的资源，例如技术支持、工具和设备等。\\n\\n5.制定时间表：制定时间表可以帮助团队成员更好地管理时间和任务。时间表应该明确任务的截止日期和所需时间，以及任务的优先顺序。\\n\\n6.定期反馈和评估：定期反馈和评估可以帮助团队成员了解自己的工作表现，并找到提高效率的方法。通过定期反馈和评估，可以发现问题并及时解决。\"\n",
      "        },\n",
      "        {\n",
      "            \"human\": \"请问在协作工具选择上有哪些建议？\",\n",
      "            \"assistant\": \"在选择协作工具时，需要根据团队的需求和特点，选择最适合的工具。以下是一些建议：\\n\\n1. 考虑团队规模：不同大小的团队需要不同的协作工具。如果团队规模很小，可以选择一些简单易用的工具，例如Trello、Google Keep等。如果团队规模较大，需要更为复杂的协作工具，例如Asana、Jira等。\\n\\n2. 考虑团队地理位置：如果团队的成员分布在不同的地理位置，需要选择支持远程协作的工具，例如Slack、Microsoft Teams等。\\n\\n3. 考虑团队的需求：不同的团队有不同的需求。需要选择具有适当功能的工具，例如任务管理、文档共享、时间追踪、沟通等。\\n\\n4. 可扩展性：选择具有可扩展性的工具，以便在团队成员增加或需求变化时，可以轻松地添加新用户或功能。\\n\\n5. 数据安全性：选择具有良好数据安全性的工具，以确保团队的数据和信息不会丢失或泄露。\\n\\n6. 价格和可用性：选择价格合理且易于使用的工具。可以选择一些免费的工具，例如Trello和Google Keep，或者付费的工具，例如Asana和Jira。\"\n",
      "        }\n",
      "    ],\n",
      "    \"dataset\": \"moss\"\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "#多轮\n",
    "item2 = {\"conversation_id\": 2, \"category\": \"Brainstorming\", \"conversation\": [{\"human\": \"请问怎样避免在项目中出现拖延？\", \"assistant\": \"避免拖延的方法有很多，以下是一些可行的建议：\\n\\n1. 制定计划和时间表：在项目开始时，制定一个详细的计划和时间表，包括每个任务的截止日期和所需时间。这样可以确保您有足够的时间来完成每个任务，并且能够更好地管理时间。\\n\\n2. 分解任务：将大型任务分解成更小、更具体的任务，这样您就可以更好地管理时间和进度。通过分解任务，您可以更好地掌握每个任务的优先级和所需时间。\\n\\n3. 减少干扰：在工作期间，尽量避免干扰和分心。关闭手机通知，将电子邮件通知设置为仅在特定时间显示，避免与同事过多的交流等。\\n\\n4. 留出缓冲时间：在计划和时间表中留出一些缓冲时间，以便在出现紧急情况或出现延误时进行调整。\\n\\n5. 与他人交流：如果您预计无法按时完成任务，请及早与团队成员或领导进行沟通。这样可以确保团队明确任务的状态，并且可以及时调整计划和时间表。\\n\\n6. 奖励自己：在完成重要任务或任务阶段后，给自己一个小小的奖励，这样可以提高自我动力，鼓励自己更好地管理时间和计划。\"}, {\"human\": \"对于一个团队来说，如何协调成员的进度和时间表？\", \"assistant\": \"协调团队成员的进度和时间表是团队管理的重要方面。以下是一些建议：\\n\\n1. 确定任务和优先级：确定团队需要完成的任务，将它们分解成更小的任务，并确定每个任务的优先级。这有助于团队成员了解哪些任务更重要，需要更多的时间和资源。\\n\\n2. 制定时间表：根据任务和优先级，制定一个时间表和截止日期。确保每个团队成员都知道自己需要在何时完成任务。\\n\\n3. 留出缓冲时间：在时间表中留出一些缓冲时间，以便团队成员可以在出现延误时进行调整。\\n\\n4. 确定团队成员的可用时间：了解每个团队成员的可用时间，例如他们是否有其他项目或任务需要完成。这有助于制定更合理的时间表，并避免出现时间冲突。\\n\\n5. 沟通和协调：定期与团队成员进行沟通，了解任务的进度和状态。如果有延误或出现问题，及时进行协调和调整时间表。\\n\\n6. 使用项目管理工具：使用项目管理工具如Trello、Asana等，可以帮助团队成员共享任务和时间表，并确保每个人都了解任务的状态和优先级。\"}, {\"human\": \"对于团队协作中出现的冲突，有什么好的解决方法吗？\", \"assistant\": \"团队协作中出现的冲突是非常常见的，以下是一些解决方法：\\n\\n1. 沟通：通过沟通，了解每个人的观点和利益，尝试达成共识。在沟通中要保持冷静，尊重他人的意见，以及表达自己的观点。\\n\\n2. 寻求中立的第三方：如果冲突无法通过沟通解决，可以寻求一个中立的第三方来帮助解决问题。这个第三方可以是团队领导、人事部门或其他人。\\n\\n3. 找出根本原因：为了解决冲突，需要找出背后的根本原因。只有了解了根本原因，才能找到解决方法。\\n\\n4. 寻找妥协方案：寻找妥协方案是解决冲突的另一种方法。通过找到双方都能接受的方案，可以解决冲突并维持团队的和谐。\\n\\n5. 集体决策：对于一些重要的决策，可以通过集体决策来解决冲突。这可以确保每个人都有机会发表意见，并在团队中达成共识。\\n\\n6. 接受和解：如果无法通过其他方法解决冲突，那么双方都需要接受和解。这意味着双方都需要放下过去的不满和情绪，重新开始合作。\"}, {\"human\": \"请问如何处理团队成员的低效率问题？\", \"assistant\": \"处理团队成员的低效率问题需要考虑以下几个方面：\\n\\n1.了解原因：了解低效率的原因是解决问题的第一步。可能有多种原因导致低效率，例如缺乏技能、缺乏经验、不明确的任务、缺乏资源等。只有了解原因，才能有针对性地解决问题。\\n\\n2.提供培训和支持：如果低效率是由于缺乏技能或经验导致的，可以提供必要的培训和支持，帮助团队成员提高技能水平和工作效率。\\n\\n3.明确任务和目标：为了避免团队成员低效率，任务和目标必须清晰明确。如果任务和目标不清晰，可能会导致团队成员浪费时间和精力，无法有效地完成任务。\\n\\n4.提供必要的资源：低效率可能是由于缺乏必要的资源导致的。为了提高工作效率，必须为团队成员提供必要的资源，例如技术支持、工具和设备等。\\n\\n5.制定时间表：制定时间表可以帮助团队成员更好地管理时间和任务。时间表应该明确任务的截止日期和所需时间，以及任务的优先顺序。\\n\\n6.定期反馈和评估：定期反馈和评估可以帮助团队成员了解自己的工作表现，并找到提高效率的方法。通过定期反馈和评估，可以发现问题并及时解决。\"}, {\"human\": \"请问在协作工具选择上有哪些建议？\", \"assistant\": \"在选择协作工具时，需要根据团队的需求和特点，选择最适合的工具。以下是一些建议：\\n\\n1. 考虑团队规模：不同大小的团队需要不同的协作工具。如果团队规模很小，可以选择一些简单易用的工具，例如Trello、Google Keep等。如果团队规模较大，需要更为复杂的协作工具，例如Asana、Jira等。\\n\\n2. 考虑团队地理位置：如果团队的成员分布在不同的地理位置，需要选择支持远程协作的工具，例如Slack、Microsoft Teams等。\\n\\n3. 考虑团队的需求：不同的团队有不同的需求。需要选择具有适当功能的工具，例如任务管理、文档共享、时间追踪、沟通等。\\n\\n4. 可扩展性：选择具有可扩展性的工具，以便在团队成员增加或需求变化时，可以轻松地添加新用户或功能。\\n\\n5. 数据安全性：选择具有良好数据安全性的工具，以确保团队的数据和信息不会丢失或泄露。\\n\\n6. 价格和可用性：选择价格合理且易于使用的工具。可以选择一些免费的工具，例如Trello和Google Keep，或者付费的工具，例如Asana和Jira。\"}], \"dataset\": \"moss\"}\n",
    "output = json.dumps(item2, indent=4, ensure_ascii=False)\n",
    "print(output)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1768083f-aadf-4a87-8f61-fe0b396c4a10",
   "metadata": {},
   "outputs": [],
   "source": [
    "!/home/sre/anaconda3/envs/bi/bin/python train_qlora.py --train_args_file baichuan-13b-qlora.json"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "924887c3-48e0-4411-b0c5-ad933b0ad987",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/bin/bash: 行 1: torchrun: 未找到命令\n"
     ]
    }
   ],
   "source": [
    "!/home/sre/anaconda3/envs/bi/bin/torchrun  --nproc_per_node=1 train_qlora.py --train_args_file baichuan-13b-qlora.json"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c183ed18-34e9-4f28-98d5-c216a523d2c5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python (bab)",
   "language": "python",
   "name": "bab"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
